package com.huibao.hulibao.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.huibao.hulibao.R;
import com.huibao.hulibao.entity.HuLiBindMomEntity;
import com.huibao.hulibao.entity.HuLiRoomEntity;

import java.util.ArrayList;

/**
 * Created by lizhaoyong on 2018/5/8.
 */
public class HuliDetailBindMomGvAdapter extends BaseAdapter {

    public ArrayList<HuLiBindMomEntity.MomData> al_datas;
    public Context context;
    public String type;


    public HuliDetailBindMomGvAdapter(Context context, ArrayList<HuLiBindMomEntity.MomData> al_datas, String type) {
        this.context = context;
        this.al_datas = al_datas;
        this.type = type;

    }

    @Override
    public int getCount() {
        return al_datas.size();
    }

    @Override
    public Object getItem(int i) {
        return al_datas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        View v = View.inflate(context, R.layout.item_gv_huli_detail, null);
        HuLiBindMomEntity.MomData md = al_datas.get(i);
        TextView tv_gv_detail_number = (TextView) v.findViewById(R.id.tv_gv_detail_number);
        TextView tv_gv_detail_name = (TextView) v.findViewById(R.id.tv_gv_detail_name);


        ArrayList<HuLiBindMomEntity.BabyData> al = md.persons;

        // 妈妈相关的显示
        if (type.equals("1")) {
            for (int j = 0; j < md.persons.size(); j++) {
                if (md.persons.get(j).IsMom.equals("1")) {
                    tv_gv_detail_name.setText("妈咪:" + md.persons.get(j).MatherName);
                    break;
                }
            }
            // 宝宝相关的显示
        } else if (type.equals("2")) {
            for (int j = 0; j < md.persons.size(); j++) {
                if (md.persons.get(j).IsMom.equals("0")) {
                    tv_gv_detail_name.setText("宝宝:" + md.persons.get(j).BabyName);
                    break;
                }
            }
        }

        if (md.roomname.equals("")) {
            tv_gv_detail_number.setText("--");
        } else {
            tv_gv_detail_number.setText(md.roomname);
        }


        return v;
    }
}
